// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import router from './router'
/*引入资源请求插件*/
import VueResource from 'vue-resource'
Vue.use(VueResource)
//引入'element-ui
import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
Vue.use(ElementUI)
Vue.config.productionTip = false
import axios from 'axios'
Vue.prototype.$ajax = axios;
// Vue.use(axios)
import VueBetterCalendar from 'vue-better-calendar'
Vue.use(VueBetterCalendar)

import Global from './api/Global'//引用文件
Vue.prototype.GLOBAL = Global;//挂载到Vue实例上面
router.beforeEach((to,from,next)=>{
  if(to.meta.needLogin){
  if(window.localStorage.getItem('uname')){
  next()
  }else{
  alert('请先登录')
  next('/login/pswdlogin')
  }
  }else{
  next()
  }
  })

/* eslint-disable no-new */
new Vue({
  el: '#app',
  router,
  components: { App },
  template: '<App/>'
})
